package com.xuecheng.media.controller;

import com.xuecheng.api.media.LiveCourseApi;
import com.xuecheng.api.media.model.ResourceUrlModel;
import com.xuecheng.api.media.model.dto.LiveCourseDTO;
import com.xuecheng.api.media.model.qo.QueryLiveCourseModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.media.common.utils.UAASecurityUtil;
import com.xuecheng.media.service.LiveCourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 直播课程 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class LiveCourseController implements LiveCourseApi {

    @Autowired
    private LiveCourseService liveCourseService;


    @Override
    @PostMapping("live/list")
    public PageVO<LiveCourseDTO> queryLiveCourseList(PageRequestParams params,
                                                     @RequestBody QueryLiveCourseModel model) {

        Long companyId = UAASecurityUtil.getCompanyId();

        return liveCourseService.queryLiveCourseList(params, model, companyId);
    }

    @GetMapping("live/pushUrl/{coursePubId}/{teachplanId}")
    public ResourceUrlModel getLivePushUrl(@PathVariable Long coursePubId, @PathVariable Long teachplanId) {
        return liveCourseService.getLivePushUrl(coursePubId, teachplanId);
    }

    @GetMapping("l/live/play-url")
    public ResourceUrlModel getLivePullUrl(@RequestParam Long coursePubId, @RequestParam Long teachplanId) {
        return liveCourseService.getLivePullUrl(coursePubId, teachplanId);
    }

}
